package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BasicStoArea;
import com.bzkj.basicinfo.service.basic.BasicStoStockService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wangzhichao
 * @ClassName BasicStoStockController
 * @Date 2024/12/13 10:47:33
 * @description 仓库信息
 */
@RestController
@RequestMapping("basic/stoStock")
public class BasicStoStockController extends BaseController {
    @Autowired
    private BasicStoStockService basicStoStockService;

    /**
     * 获取仓库信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 12:17:59
     * @Param entity
     */
    @PreAuthorize("@ss.hasPermi('index:libraryIndex:query')")
    @GetMapping("findBasicStoStockData")
    public TableDataInfo findBasicStoStockData(BasicStoArea entity) {
        startPage();
        return getDataTable(basicStoStockService.findBasicStoStockData(entity));
    }

    /**
     *
     *
     * @Author wangzhichao
     * @Date 2024/12/13 12:17:59
     * @Param entity
     */
    @PreAuthorize("@ss.hasPermi('index:libraryIndex:query')")
    @GetMapping("findAllBasicStoStockData")
    public List<BasicStoArea> findAllBasicStoStockData(BasicStoArea entity) {
        return basicStoStockService.findAllBasicStoStockData(entity);
    }

    /**
     * 修改仓库状态
     *
     * @Author wangzhichao
     * @Date 2024/12/17 17:02:29
     * @Param status
     * @Param pkStoDoc
     */
    @PreAuthorize("@ss.hasPermi('index:libraryIndex:stateEdit')")
    @PutMapping("updateBasicStoStockEnableStatus")
    @LogC(title = "仓库管理", businessType = BusinessType.UPDATE, pkFieldNames = "sto_id",
            tableNames = "basic_sto_stock"
    )
    public AjaxResult updateBasicStoStockEnableStatus(@RequestParam String status, @RequestParam String stoId) {
        return basicStoStockService.updateBasicStoStockEnableStatus(status, stoId);
    }

    /**
     * 修改仓库状态
     *
     * @Author wangzhichao
     * @Date 2024/12/17 17:02:29
     * @Param status
     * @Param pkStoDoc
     */
    @PreAuthorize("@ss.hasPermi('index:libraryIndex:stateEdit')")
    @PutMapping("updateBasicStoStockWmsEnableStatus")
    @LogC(title = "仓库管理", businessType = BusinessType.UPDATE, pkFieldNames = "sto_id",
            tableNames = "basic_sto_stock"
    )
    public AjaxResult updateBasicStoStockWmsEnableStatus(@RequestParam String status, @RequestParam(name = "stoId") String stoId) {
        return basicStoStockService.updateBasicStoStockWmsEnableStatus(status, stoId);
    }

    /**
     * 获取仓库信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 12:17:59
     * @Param entity
     */
//    @PreAuthorize("@ss.hasPermi('index:libraryIndex:query')")
    @GetMapping("/queryStoStock")
    public TableDataInfo queryStoStockList(String stoCode, String stoName) {
        startPage();
        return getDataTable(basicStoStockService.selectAllBasicStoStock(stoCode, stoName));
    }

    @GetMapping("/queryAllStoStock")
    public AjaxResult queryAllStoStock(@RequestParam(defaultValue = "",required = false) String mode,
                                       @RequestParam(defaultValue = "",required = false) String stoId,
                                       @RequestParam(defaultValue = "",required = false)String stoCode,
                                       @RequestParam(defaultValue = "",required = false)String stoName,
                                       @RequestParam(defaultValue = "",required = false)String stoAreaId,
                                       @RequestParam(defaultValue = "",required = false)String flag) {
        return basicStoStockService.queryAllStoStock(mode,stoId,stoCode, stoName,stoAreaId,flag);
    }

}
